V2EX  ›  英汉词典

Pointer Arithmetic

定义 Definition

“Pointer arithmetic”指在C/C++等语言中对指针进行加减运算(如 p+1p-2p2-p1),用于在同一数组/连续内存块中按元素大小移动位置。常见规则是:指针加1会前进一个元素(步长等于所指类型的字节数),而不是前进1个字节。该术语也常引申为“依赖内存布局进行的低层地址计算”。

发音 Pronunciation

/ˈpɔɪntər ˌærɪθˈmɛtɪk/

例句 Examples

Pointer arithmetic lets you move through an array using a pointer.
指针算术让你可以用指针在数组中逐个移动。

In C, pointer arithmetic is only well-defined within the bounds of the same array, so adding past the end can cause undefined behavior.
在C语言中,指针算术只在同一数组的边界内才有明确含义;加到数组末尾之外可能导致未定义行为。

词源 Etymology

该短语由 pointer(指针) + arithmetic(算术/算术运算) 组成。Pointer源自“point(指向)”的概念,表示“指向某处地址的引用”;arithmetic来自希腊语传统中对“数字与运算”的称呼。合起来即“对指针进行算术式的加减计算”,强调它不同于普通整数运算:其步长与所指类型大小相关。

相关词 Related Words

文学与作品 Literary Works

  • The C Programming Language(Kernighan & Ritchie)中讨论指针与数组关系时会涉及指针算术的核心规则。
  • C: A Reference Manual(Harbison & Steele)对“指针运算”的语义与约束有系统性说明。
  • Expert C Programming: Deep C Secrets(Peter van der Linden)在讲解底层实现与陷阱时频繁提到指针算术。
  • ISO C Standard(如C11/C17标准文本)在“指针加法/减法、同一数组对象范围”等条款中正式规定其行为边界。
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   2129 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 14:21 · PVG 22:21 · LAX 06:21 · JFK 09:21
♥ Do have faith in what you're doing.